package com.wuh.service.impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuh.mapper.ToeflMapper;
import com.wuh.model.ArticleType;
import com.wuh.model.Collect;
import com.wuh.model.Comment;
import com.wuh.model.Read;
import com.wuh.model.Teacher;
import com.wuh.model.Toefl;
import com.wuh.model.User;
import com.wuh.service.ToeflService;

@Service
public class ToeflServiceImpl implements ToeflService {

	@Autowired
	private ToeflMapper toeflMapper;

	@Override
	public List<Toefl> titlelist(Toefl toefl) {
		return toeflMapper.titlelist(toefl);
	}

	@Override
	public List<Toefl> titlelist2(Toefl toefl) {
		return toeflMapper.titlelist2(toefl);
	}

	@Override
	public List<Toefl> titlelist3(Toefl toefl) {
		return toeflMapper.titlelist3(toefl);
	}

	@Override
	public List<Toefl> titlelist4(Toefl toefl) {
		return toeflMapper.titlelist4(toefl);
	}

	@Override
	public List<Toefl> titlelist5(Toefl toefl) {
		return toeflMapper.titlelist5(toefl);
	}

	@Override
	public List<Toefl> titlelist6(Toefl toefl) {
		return toeflMapper.titlelist6(toefl);
	}

	@Override
	public List<Toefl> titlelist7(Toefl toefl) {
		return toeflMapper.titlelist7(toefl);
	}

	@Override
	public List<Toefl> titlelist8(Toefl toefl) {
		return toeflMapper.titlelist8(toefl);
	}

	@SuppressWarnings("null")
	public PageInfo<Toefl> getClassByat(Toefl toefl,Integer activity_type) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list = toeflMapper.getClassByat(activity_type);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}
	
	@Override
	public Toefl getArticleByai(Integer article_id) {
		return toeflMapper.getArticleByai(article_id);
	}

	@Override
	public int getCommentsumbyid(Integer article_id) {
		return toeflMapper.getCommentsumbyid(article_id);
	}

	@Override
	public PageInfo<Toefl> getComent(Comment comment,Integer article_id) {
		PageHelper.startPage(comment.getPageNum(),comment.getPageSize());
		List<Toefl> list = toeflMapper.getComent(article_id);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	public User getIdByname(String login_name) {
		return toeflMapper.getIdByname(login_name);
	}

	@Override
	public void updateCollect(Integer article_id, Integer collect_user,Date lm,Collect collect) {
		toeflMapper.updateCollect(article_id,collect_user,lm,collect);
	}

	@Override
	public int getCollectsum(Integer article_id) {
		return toeflMapper.getCollectsum(article_id);
	}

	@Override
	public void editArticle(int sum, Integer article_id) {
		toeflMapper.editArticle(sum,article_id);
	}

	@Override
	public PageInfo<Toefl> collectListBycu(Toefl toefl,Integer collect_user) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list = toeflMapper.collectListBycu(collect_user);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<Toefl> lastArticleList(Toefl toefl) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list = toeflMapper.lastArticleList(toefl);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	public Teacher getIdBytname(String a) {
		return toeflMapper.getIdBytname(a);
	}

	@Override
	public PageInfo<Toefl> getArticleBytid(Toefl toefl,Integer publish_teacher) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list = toeflMapper.getArticleBytid(publish_teacher);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	public void delArticleByid(Integer article_id) {
		toeflMapper.delArticleByid(article_id);
	}
	
	@Override
	public void delArticleByid1(Integer article_id) {
		toeflMapper.delArticleByid1(article_id);
	}
	
	@Override
	public void delArticleByid2(Integer article_id) {
		toeflMapper.delArticleByid2(article_id);
	}
	
	@Override
	public void delArticleByid3(Integer article_id) {
		toeflMapper.delArticleByid3(article_id);
	}

	@Override
	public void addAtricle(Toefl toefl) {
		toeflMapper.addAtricle(toefl);
	}

	@Override
	public void editAtricle(Toefl toefl) {
		toeflMapper.editAtricle(toefl);
	}

	@Override
	public PageInfo<Toefl> schall(Toefl toefl) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list = toeflMapper.schall(toefl);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	public PageInfo<Toefl> articleClass(Toefl toefl,Integer article_type) {
		PageHelper.startPage(toefl.getPageNum(),toefl.getPageSize());
		List<Toefl> list =toeflMapper.articleClass(article_type);
		PageInfo<Toefl> pageInfo  = new PageInfo<Toefl>(list);
		return pageInfo;
	}

	@Override
	@Transactional
	public void delArticles(Integer[] ids) {
		for(Integer id : ids) {
			toeflMapper.delArticleByid(id);
			toeflMapper.delArticleByid1(id);
			toeflMapper.delArticleByid2(id);
			toeflMapper.delArticleByid3(id);
		}
	}

	@Override
	@Transactional
	public void banArticles(Integer[] ids) {
		for(Integer id : ids) {
			toeflMapper.banArticles(id);
		}
	}
	
	@Override
	@Transactional
	public void unlashArticles(Integer[] ids) {
		for(Integer id : ids) {
			toeflMapper.unlashArticles(id);
		}
	}

	@Override
	public List<Teacher> schTeachers() {
		return toeflMapper.schTeachers();
	}
	
	@Override
	public List<ArticleType> schArticleTypes() {
		return toeflMapper.schArticleTypes();
	}

	@Override
	public void updateComment(Integer article_id, String desc, Integer comment_user, Integer publish_teacher, Date lm) {
		toeflMapper.updateComment(article_id,desc,comment_user,publish_teacher,lm);
	}
	@Override
	public void updateRead(Integer article_id, Integer read_user, Date lm, Read read) {
		toeflMapper.updateRead(article_id,read_user,lm,read);
	}

	@Override
	public int getReadsum(Integer article_id) {
		return toeflMapper.getReadsum(article_id);
	}

	@Override
	public void editRead(int sum, Integer article_id) {
		toeflMapper.editRead(sum,article_id);
	}
}
